package a05_双指针法;

/**
 * <p>
 * a01_移除元素
 * </p>
 *
 * @author flyduck
 * @since 2024-07-16
 */
public class a01_移除元素复习2 {
    public static int removeElement(int[] nums, int val) {
        int slowIdx = 0;
        for (int fastIdx = 0; fastIdx < nums.length; fastIdx++) {
            if(nums[fastIdx] != val){
                nums[slowIdx] = nums[fastIdx];
                slowIdx++;
            }
        }
        return slowIdx;

    }
}
